<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/5 0005
 * Time: 下午 5:00
 */
namespace app\index\Controller;
use think\Controller;
use think\Db;
use app\index\model\Member;
use app\index\model\Member_content;

class Register extends Controller{
    public function  skip(){
        return $this->fetch('user/registered');
    }
    public function register(){

        $user=new Member;
        $user->username=input('username');
        $user->password = input('password');
        $user->repassword=input('repassword');
        $user->email = input('email');
        $user->code =input('code');

        $result = $this->validate($user,'Vregist');
        if(true!==$result){
            echo $result;
        }
        else{
            $data1=[
                'username'=>input('username'),
                'password'=>md5(input('password'))
            ];
            $data2=[
                'email'=>input('email'),
//                'uid'=>db('member')->query('select id from member WHERE username='input('username'))
            ];

            Db('member')->insert($data1)&&Db('member_content')->insert($data2);
                //return $this->success('注册成功','login/index');
            $arr=0;
            /*$result=json_encode($arr);
            header('Content-Type:application/json');//这个类型声明非常关键
            echo $result;*/
            echo $arr;
        }

    }
}